import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
  // 自动引入
  AutoImport({
    resolvers: [
      ElementPlusResolver(),

    ],
    // dirs: [
    //   "./src/types/"
    // ],
  }),
  Icons({
    scale: 1, // Scale of icons against 1em
    defaultStyle: '', // Style apply to icons
    defaultClass: 'icones', // Class names apply to icons
    compiler: 'vue3', // 'vue2', 'vue3', 'jsx'
    jsx: 'react', // 'react' or 'preact'
    autoInstall: true,
  }),
  // 组件
  Components({
    resolvers: [
      ElementPlusResolver(),
      IconsResolver({
        prefix: "icon",//自动引入的icon前缀 默认为i
        // enabledCollections: ['ep', 'ph', 'akar'],//这是可选的,默认启用Iconify 支持的所有集合['mdi]
      })],

  })
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src")
    }
  },
  server: {
    // port: 3000,

    proxy: {
      "^/api": {
        target: "http://8.130.22.205/",
        changeOrigin: true,
        rewrite(path) {
          return path.replace(/^\/api/, '');
        },
      }
    }

  }
})
